/*
 *  Librarie de tipuri de date abstracte (TDA)
 
    Copyright (C) 2007  Catedra de Structuri de Date

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

/**
 @file linkedlist.h
 @author Florin Pop
 @brief This header file contains the structures and functions needed to work
 with priority queue.
 */

#ifndef PRIORITYQUEUE_H_
#define PRIORITYQUEUE_H_

#define PQINFINITY (0x7fffffff)

struct priorityqueue_adt;
struct priorityqueue_node;

/**
 @brief Structure representing a priority queue.
 @see See also: PQ_New(), PQ_Free()
 */
typedef struct priorityqueue_adt *PriorityQueue;
typedef struct priorityqueue_node *PQItem;

/**
@brief Creates a new priority queue, with no elements.

The function iniatlize a sequential Priority Queue which is 
able to accept up to maxLength items;
@see Adding elements should be done with PQ_Insert()
*/
PriorityQueue PQ_New(int maxLength);

/**
@brief Destroys the specified priority queue.

Memory used by the priority queue as well as all elements is freed. Thus, trying
to access the data in a destroyed priority queue will most likely
result in a Access violation / segfault.

@param pqueue the priority queue to be destroyed. A \c PriorityQueue structure.
*/
void PQ_Free(PriorityQueue pqueue);

/**
@brief Insert item into the specified priority queue.
@param pqueue the priority queue. A \c PriorityQueue structure.
@param item the item to be inserted. A \c PQItem structure.
*/
void PQ_Insert(PriorityQueue pqueue, PQItem item);

/**
@brief Find minimum item from the specified priority queue.
@param pqueue the priority queue. A \c PriorityQueue structure.
*/
PQItem PQ_ExtractMin(PriorityQueue pqueue);

/**
@brief Find minimum key item from the specified priority queue.
@param pqueue the priority queue. A \c PriorityQueue structure.
*/
int PQ_ExtractMinKey(PriorityQueue pqueue);

/**
@brief Find minimum data item from the specified priority queue.
@param pqueue the priority queue. A \c PriorityQueue structure.
*/
void* PQ_ExtractMinData(PriorityQueue pqueue);

/**
@brief Delete the minimum item from specified priority queue.
@param pqueue the priority queue. A \c PriorityQueue structure.
*/
void PQ_DeleteMin(PriorityQueue pqueue);

/**
@brief Return how many items are in this priority queue.
@param pqueue the priority queue. A \c PriorityQueue structure.
*/
int PQ_Length(PriorityQueue pqueue);

#endif /*PRIORITYQUEUE_H_*/
